#!/usr/bin/perl

use strict;

package Lunmgr::TableEntry;

use Carp;
our $AUTOLOAD;

sub new
{
    my ($proto, $line) = @_;

    my $class = ref($proto) || $proto;

    my $self = {};
    @{$self}{'_uuid', '_model', '_wwn:lun', '_mount_pt', '_name'} 
        = split(/\s+/, $line);
    @{$self}{'_wwn', '_lun'} = split(/:/, $self->{'_wwn:lun'});

    bless $self, $class;

    return $self;
}

sub AUTOLOAD
{
    my $self = $_[0];

    my $attr = $AUTOLOAD;
    $attr =~ s/.*:://;

    return $self->{"_$attr"} if exists $self->{"_$attr"};

    carp "Invalid call for $AUTOLOAD";
    undef;
}

sub path { $_[0]->{_mount_pt} . "/" . $_[0]->{_name}; }
sub DESTROY {}

use overload q("") => sub { 
        my $self = $_[0];
        join ' ', 
             @{$self}{'_uuid', '_model', '_wwn:lun', '_mount_pt', '_name'};
    };
    
1;
